package cc.taofoo.IO.socket;

import java.io.IOException;
import java.io.InputStreamReader;
import java.net.Socket;
import java.net.SocketAddress;

public class Client extends Thread {
    Socket socket ;

    public Client(){
        try {
            socket = new Socket("127.0.0.1",12589);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    @Override
    public void run() {
        System.out.print(Thread.currentThread().getName()+": ");
        try {
            int x;
            InputStreamReader isr = new InputStreamReader(socket.getInputStream());
            while ((x=isr.read())!=-1)
                System.out.print((char)x);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
